package com.kancy.vip.pattern.proxy.dynamicproxy.myjdk;

import com.kancy.vip.pattern.proxy.Girl;
import com.kancy.vip.pattern.proxy.Love;
import com.kancy.vip.pattern.proxy.staticproxy.Boy;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author kancy
 * @date 2019/3/17 16:28
 */
public class MyProxyTests {

	public static void main(String[] args) throws Exception {

		Girl target = new Girl();

		Love o = (Love) MyProxy.newProxyInstance(Love.class.getClassLoader()
				, new Class[]{Love.class}, new MyInvocattion() {
					@Override
					public Object invoke(Object proxy, Method method, Object[] params) throws InvocationTargetException, IllegalAccessException {
						System.out.println(method);
						return method.invoke(target, params);
					}
				});

		Boy kancy = new Boy("kancy", 24, 176);
		boolean love = o.findLove(kancy);
		System.out.println(love);

	}
}
